package com.sx.manage.controller.city;

import java.io.IOException;
import java.util.ArrayList;
import java.util.List;

import javax.annotation.Resource;
import javax.servlet.ServletException;

import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.sx.manage.controller.base.MBaseController;
import com.sx.manage.service.city.IMBaseCityService;
import com.sx.model.manage.mybatis.form.bank.MCityForm;
import com.sx.model.manage.mybatis.vo.bank.MDropDownVO;
import com.sx.model.manage.mybatis.vo.result.ResultDropDownListVO;

@Controller
@RequestMapping("/cityInfo")
public class MCityInfoController extends MBaseController {

	private Logger log = LoggerFactory.getLogger(this.getClass());
	@Resource(name = "mBaseCityServiceImpl")
	private IMBaseCityService mBaseCityServiceImpl;

	/**
	 * 城市下拉
	 * 
	 * @param request
	 * @param upCodeId
	 * @return
	 * @throws ServletException
	 * @throws IOException
	 */
	@RequestMapping("/query_city")
	@ResponseBody
	public ResultDropDownListVO<MDropDownVO> query_cityInfo_dropdown(MCityForm form) throws IOException {
		log.info("查询银行下拉框form={}",form);
		if (StringUtils.isBlank(form.getChannel_type())) {
			MDropDownVO downVO = new MDropDownVO();
			downVO.setText("请选择开户渠道");
			List<MDropDownVO> list = new ArrayList<>();
			list.add(downVO);
			log.info("开户渠道为空form={}",form);
			return new ResultDropDownListVO<>(list, 1, 1, 1);
		}
		if (0 == form.getUp_code_id()) {
			MDropDownVO downVO = new MDropDownVO();
			downVO.setText("请选择省份");
			List<MDropDownVO> list = new ArrayList<>();
			list.add(downVO);
			log.info("请先选择省份form={}",form);
			return new ResultDropDownListVO<>(list, 1, 1, 1);
		}
		return mBaseCityServiceImpl.query_cityInfo_dropdown(form);
	}
}
